" vimrc_noReplaceUncommonCharacters
" Normal mode {{{1
" Current file operation {{{2
nnoremap <space>f :w !diff - %<cr>

nnoremap <space>w :w<cr>

nnoremap <space>q :q<cr>
nnoremap <space><space>q :qa!<cr>

nnoremap <space>x :x<cr>
nnoremap <space><space>x :xa!<cr>

" Buffer operations {{{2
nnoremap <space>j :bnext<cr>

nnoremap <space>k :bprevious<cr>

nnoremap <space>b :bdelete<cr>
nnoremap <space><space>b :bdelete!<cr>

" Easier macro {{{2
nnoremap Q @q
nnoremap K @k
nnoremap - @@
nnoremap + @:

" Quick movements {{{2
nnoremap <space>l $
xnoremap <space>l $

" <space>6 for switching between 2 buffers
nnoremap <space>6 <c-^>

" Jump to first character or column
function! FirstCharOrFirstColFunction()
  let current_col = virtcol('.')
  normal g^^
  let first_char = virtcol('.')
  if current_col == first_char
    normal g00
  endif
endfunction

nnoremap <silent> <space>h :call FirstCharOrFirstColFunction()<cr>
xnoremap <space>h g^^

" Toggler {{{2
nnoremap <space>ts :set spell!<cr>
nnoremap <space>tw :set wrap!<cr>
nnoremap <space>tc :ChangeColorscheme<cr>
nnoremap <space>tn :set number! relativenumber! <bar> SignifyToggle<cr>
nnoremap <space>tp :set paste<cr>
nnoremap <space>tr :redraw!<cr>

" Misc {{{2
nnoremap <space>n <c-w><c-w>

" press enter insert a new line while remaining in normal mode
nnoremap <cr> O<esc>j

" Ex command mode {{{1
" Quick horizontal movements {{{2
cnoremap <c-h> <left>
cnoremap <c-l> <right>
cnoremap <c-a> <home>
cnoremap <c-e> <end>
cnoremap <c-x> <BS>
cnoremap <c-d> <delete>

" Abbreviations {{{2
cnoremap zkq q!<cr>
cnoremap zke e!<cr>
cnoremap zkw w!<cr>
cnoremap zkx x!<cr>
cnoremap zkb bd!<cr>
cnoremap zkl lcd %:p:h<cr>
cnoremap zks w<bar>so %<cr>
cnoremap zkt w! /tmp/tmp<cr>

" vimgrep {{{2
cnoremap zkg vimgrep  src/** test/**<left><left><left><left><left><left><left><left><left><left><left><left><left><left><left>

" Insert mode {{{1
" Quick escape {{{2
inoremap jl 
inoremap Jl 
inoremap jL 
inoremap JL 

" Auto-completion {{{2
" line complete
inoremap zl 
inoremap zf 

" auto set spell for dictionary complete
inoremap <c-x><c-k> <esc>:set spell<cr>a<c-x><c-k><c-p>

" Quick put {{{2
inoremap zp "
inoremap z<space>p +

" Quick backward deletion {{{2
inoremap zb 
inoremap zx <BS>

" Visual mode {{{1
" Reselect the recently copied
nnoremap gV `[v`]
" Reformat the recently copied
nnoremap g= `[v`]=
" blackhold delete
xnoremap <bs> "_d

" System {{{1
" System clipboard {{{2
nnoremap <space>p "+p`]
nnoremap <space>P "+P`]
nnoremap <space>y "+y`]
nnoremap <space>Y "+Y`]
nnoremap <space>d "+d
nnoremap <space>D "+D

xnoremap <space>p "+p`]
xnoremap <space>P "+P`]
xnoremap <space>y "+y`]
xnoremap <space>Y "+Y`]
xnoremap <space>d "+d
xnoremap <space>D "+D
xnoremap <space>x "+x
xnoremap <space>X "+X

